package com.atguigu.gmall.task;

import com.atguigu.gmall.common.constans.MqConst;
import com.atguigu.gmall.common.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author 李旭
 * @date 2022/2/9
 * @Description:
 *
 *   定时器任务
 *
 */
@Component
public class Task0 {


    @Autowired
    private RabbitService rabbitService;

    //定时器  半夜 11点   12点
    //@Scheduled(cron = "0 0 0 * * ?")
    //@Scheduled(cron = "0 0 23 * * ?")
    @Scheduled(cron = "0/5 * * * * ?")
    public void task0(){
        System.out.println("本次是每5S执行一次定时器任务.....");
        //发消息    MQ   闹铃
        rabbitService.sendMessage(MqConst.EXCHANGE_DIRECT_TASK,
                MqConst.ROUTING_TASK_1,"");
    }

}
